package ynu.dao;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import ynu.po.UserList;
import java.util.List;

@Repository  //spring bean
public interface IUserListDao extends CrudRepository<UserList, Long> {
    boolean existsByEmail(String email);
    boolean existsByUserName(String userName);

    UserList findUserListByUserName(String name);

    UserList findUserListByUserNameAndCareer(String name,String career);

    List<UserList> findAll();

    List<UserList> findUserByAgeBetweenAndSexIsAndUserNameContaining(Integer min, Integer max, Boolean sex, String name);

    UserList findUsersByUserIdAndPassword(Long id, String password);

    @Query("select s from UserList s where (s.age between :min and :max) and s.sex =:sex ")
    List<UserList> queryFitUserList(@Param("max") Integer maxValue, @Param("min") Integer minValue, @Param("sex") Boolean sex);

    @Query("select s from UserList s where (s.age between ?1 and ?2) and s.sex =?3 ")
    List<UserList> queryFitUserList2(Integer min, Integer max, Boolean sex);



}
